<template>
  <view class="contentI">
    <view class="cont" v-if="purchaseData.length != 0">
      <view
        class="item"
        v-for="(item, index) in purchaseData"
        :key="index"
        @click="
          handleTabs(
            '/pages/Trade/Tradedetails?Group_Seek_Purchase_SerialNumber=' +
              item.Group_Seek_Purchase_SerialNumber +
              '&Enterprise_Info_SerialNumber=' +
              item.Enterprise_Info_SerialNumber
          )
        "
      >
        <!-- <view class="leftimg">
          <image :src="Domain_IMG + item.Enterprise_Logo" mode="scaleToFill" />
        </view> -->
        <view class="right">
          <view class="title">{{ item.Article_Name }}</view>
          <view class="jg">{{ item.Amount + "/" + item.Unit }}</view>
          <view class="fl">{{ item.Category_Name }}</view>
          <view class="cont2">
            <view class="left">
              <view class="view">发布人:{{ item.Contacts }} </view>
              <view class="view">所属企业 :{{ item.Enterprise_Name }} </view>
            </view>
          </view>
          <view class="but"> 查看详情 </view>
        </view>
      </view>
    </view>
    <view class="contI" v-else="purchaseData.length == 0"> 暂无数据 </view>
  </view>
</template>

<script>
const app = getApp();
import {
  GroupSeekProcureAll,
  GroupSeekProcureAllAction,
  GroupProcureAll,
  GroupProcureAllAction,
  GroupProcureStatistics,
  GroupGoodsAll,
} from "@/api/group.js";
export default {
  name: "Tender",
  data() {
    return {
      purchaseform: {
        Article_Name: "",
        Category_SerialNumber: "",
        Enterprise_Info_SerialNumber: "",
        Type: "0",
        token: "",
        page: 1, //页数
        limit: 10, //每页数据条数
      },
      purchaseData: [],
      total: 0,
      Domain_IMG: app.globalData.Domain_IMG,
    };
  },
  props: {
    limit: {
      type: Number,
      default: 4,
    },
    page: {
      type: Number,
      default: 1,
    },
    Article_Name: {
      type: String,
      default: "",
    },
    Category_SerialNumber: {
      type: String,
      default: "",
    },
  },
  watch: {
    page: function (Newvalue, Oldvalue) {
      this.form.page = Newvalue;
      this.getAuctiontransactions(this.form);
    },
    Article_Name: function (Newvalue, Oldvalue) {
      this.form.page = 1;
      this.form.Article_Name = Newvalue;
      this.getAuctiontransactions(this.form);
    },
    Category_SerialNumber: function (Newvalue, Oldvalue) {
      this.form.page = 1;
      this.form.Category_SerialNumber = Newvalue;
      this.getAuctiontransactions(this.form);
    },
  },

  methods: {
    handleTabs(url) {
      uni.navigateTo({
        url,
      });
    },
    //Tradedetails
    async getData(purchaseform) {
      console.log(1);
      uni.showLoading({
        title: "加载中...",
      });
      const res2 = await GroupSeekProcureAllAction({
        data: purchaseform,
      });
      if (
        (res2.redirect && res2.redirect == "REDIRECT") ||
        res2.REDIRECT == "REDIRECT"
      ) {
        uni.removeStorageSync("token");
        const res2 = await GroupSeekProcureAll({
          data: purchaseform,
        });
        if (res2.Status == "success") {
          this.purchaseData = res2.tableData;
        }
      } else if (res2.Status == "success") {
        this.purchaseData = res2.tableData;
        console.log(this.purchaseData);
      }
      uni.hideLoading();
    },
  },
  onLoad(options) {
    // console.log(options);
    this.getData(this.purchaseform);
  },
  created() {
    this.getData(this.purchaseform);
  },
};
</script>

<style lang="scss">
.contentI {
  width: 100%;
  // height: calc(100vh - 94px);
  background-color: #f5f5f5;
  padding: 0 0 20rpx 0;
  box-sizing: border-box;
  .cont {
    height: calc(100vh -44px);
    padding: 20rpx;
    box-sizing: border-box;
    background-color: #f5f5f5;

    .item {
      border-radius: 20rpx;
      background-color: #fff;
      padding: 25rpx;
      box-sizing: border-box;
      margin: 0 0 30rpx 0;
      display: flex;
      // width: 60%;
      .leftimg {
        display: flex;
        align-items: center;
        justify-content: center;

        .image {
          width: 258rpx;
          height: 258rpx;
          border-radius: 20rpx;
          margin: 0 10rpx 0 0;
        }
      }
      .right {
        width: 60%;
        padding: 10rpx;
        box-sizing: border-box;
        flex: 1;
        .fl {
          font-size: 28rpx;
        }
      }
      .title {
        font-size: 34rpx;
        color: #222;
        line-height: 34rpx;
        font-weight: 500;
      }
      .jg {
        font-size: 34rpx;
        color: #ff442f;
        vertical-align: middle;
        margin-right: 20rpx;
        // flex: 0 0 auto;
        margin: 20rpx 0 20rpx;
      }
      .cont2 {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .left {
          font-size: 26rpx;
          color: rgba(34, 34, 34, 0.5);
          line-height: 26rpx;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          .view {
            margin-top: 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
      .but {
        margin: 20rpx 0 0 0;
        width: 132rpx;
        height: 54rpx;
        border: 1px solid #39bf3e;
        border-radius: 28rpx;
        font-size: 26rpx;
        color: #39bf3e;
        text-align: center;
        letter-spacing: 0;
        font-weight: 500;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }
  .contI {
    height: calc(100vh - 50px);
    color: #222;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }
}
</style>